package com.qyh.test;

import com.qyh.hhh.ToggleContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@SpringBootApplication
@RestController
public class SimpleToggleExampleApplication {

    @Autowired
    @Qualifier("defaultHelloService")
    private HelloService helloService;

    public static void main(String[] args) {
        SpringApplication.run(SimpleToggleExampleApplication.class, args);
    }

    @GetMapping("/test")
    public String test1() {
        List<String> names = Arrays.asList("张三", "李四");
        return helloService.test1(names);
    }

    @GetMapping("test2/{tenantID}")
    public String test2(@PathVariable Integer tenantID) {
        // 给变量设置值
        ToggleContextHolder.setParam(tenantID);
        return this.helloService.test2("张三");
    }
}
